<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>工程签证管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../resources/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../resources/css/style.css" media="all">
    <style>
        /*.layui-form-pane .layui-input-block{margin-left: 82px;}*/
        .saixuan:after{width: 0;}
        .layui-form-pane .layui-input-block{margin-left: 0;}

        @media screen and (max-width: 1280px) {
            .layui-form-pane .layui-form-label{width: 108px;}
        }
        .layui-form-item .layui-input-inline{width: 165px;}
        .masksx .forms{padding-left: 0;text-align: center;}
        .masksx{width: 650px;}
        .mask input{width: 100%!important;}
        .mask .layui-select-title{width: 480px;}
        .layui-inline{margin-bottom: 10px;}
        .layui-upload{ text-align: left;}
        #demo2 img{width: 120px; height: 120px;}
        .imgs{position: relative;width: 120px; height: 120px; float: left;}
        ._ingshan{position: absolute;right: 0px;top: 0px;border: 1px solid #E3e3e3;
            border-radius: 50%;width: 20px;height: 20px;text-align: center;}
        @media only screen and (min-width: 321px) and (max-width: 1024px) {
            .layui-form-pane .layui-input-inline {width: 100%;}
            ._inkong{ width:auto!important; }
            .layui-form-item .layui-input-inline{width: 100%;}
            .masksx{height: 50%;}
        }
        @media screen and (max-width: 750px){
            .MOVE_queryon .layui-form-item {
                width: 80%;
            }
            .layui-form-item{padding: 0;}
            .MOVE_footer{text-align: right;}
            .MOVE_footer a{color: #FFF;font-size: 20px;line-height: 30px;
                padding: 10px;background-color: #F5A721;height: 100%;position: absolute;right: 0;}
            .tijiao{z-index: 9999;}
        }
        .danhao{display: none; padding-left: 32px;}
        .danhao .layui-form-label,.danhao ._inkong{float: left;}
        .danhao ._inkong{margin-bottom: 10px; }
        .masksx ._inkong{}
        .layui-table-cell{text-align: left;}
        .layui-form-select,.layui-input-inline{width: 80%!important;}
    </style>
</head>
<body>
<div class="_PC">
    <a class="dayin" type="button" id="dlink"  style="float: right; position: fixed; right: 50px; bottom: 50px; z-index: 999;"></a>
    <form class="layui-form layui-form-pane" id="form_7grid" action="" >
        <div class="formTop layui-row">
            <div class="layui-form-item layui-col-lg3 layui-col-md3 layui-col-xs3">
                <div class="layui-input-inline">
                    <input type="text" name="cc_code"  placeholder="项目名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline layui-col-lg3 layui-col-md3 layui-col-xs3">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="test-limit3" placeholder="请选择开始日期">
                    <div class="icons">

                    </div>
                </div>
            </div>
            <div class="layui-inline layui-col-lg3 layui-col-md3 layui-col-xs3">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="test-limit4" placeholder="请选择结束日期">
                    <div class="icons">

                    </div>
                </div>
            </div>

            <div class="layui-col-lg3 layui-col-md3 layui-col-xs3">
                <button class="layui-btn" type="button" onclick="query()" style="margin-right: 30px;">查询
                </button>
                <button class="layui-btn shenqingvisa quanxian" type="button"  style="background-color:
            #FE913F;" QX="api/buil/builSignHisBao.do">申请签证</button>

            </div>

        </div>

        <table id="demo" lay-filter="test"></table>

        <div id="demo7"></div>

        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-sm quanxian" lay-event="detail" QX="api/buil/builSignHisDetail.do">查看</a>
            <a class="layui-btn layui-btn-sm layui-btn-danger bianji quanxian" lay-event="toExamine" QX="api/buil/builSignHisBaoEdit.do">编辑</a>
        </script>

        <div class="mask">
            <div class="masksx">
                <div class="title"><span class="titleL">申请签证</span><span class="close">×</span></div>
                <div class="forms">
                    <form class="layui-form addUser" method="post" action="">

                        <div class="layui-inline danhao">
                            <label class="layui-form-label">单号:</label>
                            <div class="layui-input-inline _inkong" style="width: 480px;">
                                <input type="text" name="cs_id" lay-verify="title" autocomplete="off" placeholder="" class="layui-input" disabled="disabled">
                                <input type="hidden" name="buil_code" lay-verify="title" autocomplete="off" placeholder="请输入" class="layui-input" value="001">

                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">工程名称:</label>
                            <div class="layui-input-inline _inkong">
                                <select name="cc_uuid" lay-verify="required" lay-search="">
                                    <option value="">直接选择或搜索选择</option>


                                </select>
                            </div>
                        </div>
                        <div class="layui-inline" style="width:100%;padding: 0 30px;">
                            <label class="layui-form-label">签证人:</label>
                            <div class="layui-input-inline _inkong" style="width: 74%!important;padding-right: 50px;">
                                <input type="text" name="s_person" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">

                            </div>
                        </div>

                        <div class="layui-inline" style="width: 93%;padding-left: 13px;">
                            <label class="layui-form-label">签证内容</label>
                            <div class="layui-input-inline" style="width: 480px;">
                                <textarea placeholder="请输入内容" class="layui-textarea" name="s_content"></textarea>
                            </div>
                        </div>
                        <div class="layui-inline" style="margin-bottom: 10px;width: 93%;padding-left: 13px;">
                            <label class="layui-form-label">现场图</label>
                            <div class="layui-input-inline" style="width: 480px;">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" id="test2" style="width: 130px;height: 130px; background-color: #F3F3F3; color: #B7B7B7; border-radius: 5px;"><i class="layui-icon" style="font-size: 83px;">&#xe654;</i> </button>
                                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;width:
                                335px;float: right;margin: 0;padding: 0;border: 0;">
                                        <div class="layui-upload-list" id="demo2" style="margin: 0;"></div>
                                    </blockquote>
                                </div>


                            </div>
                        </div>
                        <div class="_submit">
                            <button class="layui-btn layui-btn-sm tijiao" lay-submit lay-filter="_subm">提交</button>
                            <button class="layui-btn layui-btn-sm " type="reset">重置</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </form>
</div>



<script src="../../../resources/layui/layui.js" charset="utf-8"></script>
<script src="../../../resources/js/style.js"></script>
<script src="../../../resources/js/api.js"></script>

<script>
    function query() {
        layui.use(['form', 'layedit', 'laydate','table','element','upload'], function() {
            var form = layui.form
                , table = layui.table
                ,upload = layui.upload;
            var pronName=$("[name='cc_code']").val();      //获取查询值
            var begintime=$('#test-limit3').val();          //获取查询开始时间
            var endtime=$('#test-limit4').val();            //获取查询结束时间
            var state=$('[name="state"]').val();         //获取状态值
            $('#form_7grid').attr('action',urls+'/api/contract/conValiList.do')
            if(!AntiSqlValid(pronName)){           //判断是否包含特殊符号
                if(lbq('api/buil/builSignHisList.do')) {

                    API.visaAdmin({
                        'proName': pronName,
                        'begintime': begintime,
                        'endtime': endtime,
                        'state': state,
                        'p': getCookie('yanzheng')
                    })
                }
            }else {
                layer.msg('请勿输入特殊符号或敏感文字');
            };
        })

    }
    layui.use(['form', 'layedit', 'laydate','table','element','upload','flow'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate
            ,table=layui.table
            ,element=layui.element
            ,flow=layui.flow
            ,upload = layui.upload;
        var _picurls=new Array();
        jiazais();

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';        //代替另一个对象调用一个方法。call 方法可将一个函数的对象上下文从初始的上下文改变为由 thisObj 指定的新对象。
        });
        if(lbq('api/buil/builSignHisList.do')){
            API.visaAdmin({'p':getCookie('yanzheng')},function(){
                //console.log(arguments, '-----------');
                xiala=arguments[0].contracts;
                //console.log(xiala);


            });

        }
        dayintishi('.dayin');
        $("[name='cc_uuid']").html('')
        ajaxs('/api/public/loadPriDropDown.do','post',{'type':'d','p':getCookie('yanzheng')},function (data) {
            //console.log(data)
            var datas=data.data;
            for(var i=0;i<datas.length;i++){

                $("[name='cc_uuid']").append('<option value="'+datas[i].cc_UUID+'">'+datas[i].eppName+'('+datas[i].eppStaEnd+')'+'</option>');
            };
            form.render();
        });


        //图片上传
        upload.render({
            elem: '#test2'
            ,url: urls+'/api/public/uploadImg.do'
            ,multiple: true
            ,size:1024*10
            ,before: function(obj){
                //预读本地文件示例，不支持ie8

            }
            ,done: function(res){
                //上传完毕
                //console.log(res)
                _picurls.push(res.data[0]);         //返回的数据  放进数组中以便传递

                    $('#demo2').append('<div class="imgs"><img src="'+ urls+'/'+res.data[0] +'" class="layui-upload-img"> <span class="_ingshan"><i class="layui-icon">&#x1006;</i> </span></div>')
                //console.log(_picurls)

            }
            ,error: function(index, upload){
                //当上传失败时，你可以生成一个“重新上传”的按钮，点击该按钮时，执行 upload() 方法即可实现重新上传
                //console.log(index,upload)
            }
        });

        //前后若干天可选，这里设置不能选过去的日期      最远可选1000天之后
        panduanshijiantow('#test-limit3','#test-limit4',1000,1000,'.layui-btn-normal');     //查询 开始结束时间判断


        //日期  不弹出解决方法
        laydate.render({
            elem: '#date'
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#date1'
            ,type: 'datetime'
        });
        var dengluR=getCookie('yanzheng');
        dengluR=dengluR.split('|');
        //console.log(dengluR)

        $('.shenqingvisa').click(function () {

            $('.mask').show();
            $('.danhao').hide();
            $('.titleL').html('申请签证');
            $('[name="cc_uuid"]').val('');
            $('[name="cc_uuid"]').removeAttr('disabled');
            $('.forms input').val('');
            $('.forms textarea').val('');
            $('.imgs').remove();
            $('[name="s_person"]').val(dengluR[0]);
            $('.tijiao').attr('lay-filter','_subm');
            form.render();
        })

        $('.close').click(function () {     //遮罩层隐藏
            $('.mask').hide();
        })
        var id='';
        var imgs='';
        //监听工具条
        table.on('tool(test)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            var tr = obj.tr; //获得当前行 tr 的DOM对象

            if(layEvent === 'detail'){ //查看
                //do somehing
                //console.log(obj)
                sessionStorage.cs_id=obj.data.cs_id;
                sessionStorage.stear='detail';                //拼接上detail  跳转页面判断
                window.location.href='./visaAdminDE.html';
            }else if( layEvent==='toExamine'){      //编辑
                $('.titleL').html('编辑')
                $('.mask').show();
                $('.danhao').show();
                $('.imgs').remove();
                $('.tijiao').attr('lay-filter','bianji')
                //console.log(obj)
                imgs=obj.data.s_Img;
                $('[name="cc_uuid"]').val(obj.data.cc_UUID);
                $('[name="s_person"]').val(obj.data.createUser);
                $('[name="cs_id"]').val(obj.data.cs_id);
                $('[name="s_content"]').val(obj.data.s_Content);
                $('[name="cc_uuid"]').attr('disabled',true)
                var img_arr=new Array();
                //console.log(obj.data.s_Img.length)

                if(obj.data.s_Img.length){
                    img_arr=obj.data.s_Img;
                img_arr=img_arr.split(',');
                    for(var i=0;i<img_arr.length;i++){
                        $('#demo2').append('<div class="imgs"><img src="'+ urls+'/'+img_arr[i] +'" class="layui-upload-img"> <span class="_ingshan"><i class="layui-icon">&#x1006;</i> </span></div>')
                    }
                }

                id=obj.data.cs_id;
                $('.layui-disabled').attr('disabled',true);

                form.render();
            }
        });

        $(document).on('click','._ingshan',function () {
            //console.log($(this).prev().attr('src'))
            var shanSRC=$(this).prev().attr('src');
            $(this).parent().remove();
            $.each(_picurls,function(index,item){       //删除功能
                // index是索引值（即下标）   item是每次遍历得到的值；
                if(item==shanSRC){
                    _picurls.splice(index,1);
                }
            });

            //console.log(_picurls)
        })
        form.on('submit(_subm)',function (data) {
            //console.log(data.field)
            //console.log(_picurls)
            data.field.s_img=_picurls.toString();
            data.field.buil_code='001';
            data.field.p=getCookie('yanzheng');
            formAlertAjax('/api/buil/builSignHisBao.do',data.field,'.tijiao');


            return false;
        })          //监听提交

        form.on('submit(bianji)',function (data) {
            //console.log(data.field)
            var imgas='';
            $('.imgs').each(function (k,v) {

                imgas+=$(v).children('img').attr('src')+',';
            })
            imgas=imgas.substring(0,imgas.length-1);
            imgas=imgas.replace(/http:\/\/gcjs.hntxrj.com\//g, '')
            //console.log(imgas)



            data.field.s_img=imgas;
            data.field.cs_id=id;
            data.field.p=getCookie('yanzheng');
            formAlertAjax('/api/buil/builSignHisBaoEdit.do',data.field,'.tijiao');


            return false;
        })          //监听提交



    })




</script>
</body>
</html>